﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace OnlineMediaAnalyzer.Models
{
    public enum Sentiment
    {
        positive,
        negative,
        neutral,
        conflicting,
        extreme
    }

    public class Article
    {
        public int ID { get; set; }

        [Required(ErrorMessage="Identificator is required")]
        [StringLength(256, ErrorMessage = "Identificator length should be less than 256")]
        public string Identification { get; set; }

        [Required(ErrorMessage="Title is required")]
        [StringLength(256, ErrorMessage = "Title length must be less than 256")]
        public string Title { get; set; }

        //[Required(ErrorMessage="Description is required")]
        [StringLength(1024, ErrorMessage = "Description length should be less than 1024")]
        public string Description { get; set; }

        //[Required(ErrorMessage="Url is required")]
        [StringLength(256, ErrorMessage = "Url length should be less than 256")]
        public string Url { get; set; }

        public DateTime Time { get; set; }

        [Required(ErrorMessage="Author is required")]
        [StringLength(64, ErrorMessage = "Author name length should be less than 64")]
        public string Author { get; set; }

        [Required(ErrorMessage = "Fetching time is required")]
        public DateTime FetchingTime { get; set; }

        public int FeedID { get; set; }
        public virtual Feed Feed { get; set; }

        public Sentiment? Sentiment { get; set; }

        public virtual ICollection<Category> Categories { get; set; }

        [StringLength(32)]
        public string Self
        {
            get
            {
                return string.Format(CultureInfo.CurrentCulture,
                    "api/articles/{0}", this.ID);
            }
            set { }
        }
    }
}